package com.xiangshizhineng.tianzhangzhi.app.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiangshizhineng.tianzhangzhi.app.model.response.TaskHistoryResponse;
import com.xiangshizhineng.tianzhangzhi.app.model.response.TaskResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author Administrator
 * @Desc
 * @date 2022/2/14 14:32
 */
@Mapper
public interface TaskHistoryDAO extends BaseMapper<TaskHistoryResponse> {
    /**
     * 历史任务批次分页
     */
    @Select("select sum(task_status_id=20) fin_task,count(id) all_task,production,task_s_time,task_e_time,task_type_id," +
            "case when sum(task_status_id=21) =0 then 0 else 1 end whole_status,xzqhdm from tz_task_history t ${ew.customSqlSegment}")
    IPage<TaskHistoryResponse> selectHistoryByProduction(@Param("page") Page page, @Param(Constants.WRAPPER) Wrapper<TaskHistoryResponse> taskHistoryWrapper);
}
